package com.yidu.DailyFinalTreatment.mapper;

import com.yidu.BusinessData.service.impl.BondServiceImlp;
import com.yidu.BusinessParameters.entity.CashAccruedEntity;
import com.yidu.BusinessParameters.entity.SecurityAccruedEntity;
import com.yidu.DailyFinalTreatment.entity.BondInterestIncomeEntity;
import com.yidu.DailyFinalTreatment.entity.IncomePaymentEntity;
import com.yidu.DailyFinalTreatment.entity.PayTwoFeesEntity;
import com.yidu.StockControl.entity.CashInventory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Mapper
@Resource
public interface IncomePaymentMapper {
    //@Select("select i.cashInventorysTime,i.balance,s.accounName,s.cashType,m.allocateFlow from (SELECT * FROM cashInventorys where ${date}) i join fund f on i.fundId=f.fundId join cash s on i.cashId=s.cashId JOIN moneyAllocate m ON i.cashId=m.cashId group by cashInventorysId limit #{page},#{limit}; \n")
   @Select("SELECT * FROM (SELECT * FROM cashInventory where ${date}) c JOIN cash a ON c.cashId = a.cashId limit #{page},#{limit}")
   public List<IncomePaymentEntity> selectCashInterestIncome(Map map);
   // @Select("SELECT s.securityName,s.securityType,s.securityTotalAmount,s.securityInventoryTime,m.allocateFlow FROM (select * from securityInventory where ${date}) s  JOIN moneyAllocate m ON m.fundId = s.fundId group by securityInventoryId limit #{page},#{limit}")
    @Select("SELECT * FROM securityInventory where ${date} limit #{page},#{limit} ")
    public List<BondInterestIncomeEntity> selectBondInterestIncome(Map map);
    @Select("SELECT c.*,a.accounName FROM (select * from cashInventory where ${date} and businessType=2 || businessType=1) c JOIN cash a ON a.cashId=c.cashId group by cashInventoryId limit #{page},#{limit} ")
    public List<PayTwoFeesEntity> selectPayTwoFees(Map map);



    //c查询BondInterestIncomeEntity 的Idand securityType = #{securityType} }
    @Select("SELECT securityAccruedId FROM securityAccrued where securityDate = #{securityDate} and money = #{money} and businessType = #{businessType} and moneyFlow = #{moneyFlow} ")
    public List<String> selectBondInterestIncomeID(SecurityAccruedEntity bondInterestIncomeEntity);
    //现金查询
    @Select("SELECT * FROM cashAccrued where cashDate = #{cashDate} and moneySun = #{moneySun} and moneyFlow = #{moneyFlow} and businessType = #{businessType}  ")
    public List<CashAccruedEntity> cashAccruedID(CashAccruedEntity cashAccrued);

    @Delete("delete from securityInventory where securityInventoryId = #{securityInventoryId}")
    public int deleteBondInterestIncomeID(String securityInventoryId);

}
